package com.mes.cloud.web;

import com.mes.cloud.api.dto.request.organization.SysOrganizationAreaRequest;
import com.mes.cloud.api.dto.response.organization.SysOrganizationAreaDto;
import com.mes.cloud.common.JsonResult;
import com.mes.cloud.enums.HttpStatusEnum;
import com.mes.cloud.service.SysOrganizationAreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author xy
 * @version 2019-08-01 10:47:27
 * @email yuan.xue3@pactera.com
 */
@Api(tags = "组织行政区中间", value = "组织行政区中间接口")
@RestController
@RequestMapping(value = "/sysOrganizationArea")
public class SysOrganizationAreaController  {

    private SysOrganizationAreaService sysOrganizationAreaService;

    @Autowired
    public SysOrganizationAreaController(SysOrganizationAreaService sysOrganizationAreaService) {
        this.sysOrganizationAreaService = sysOrganizationAreaService;
    }

    /**
     * <查询组织已有行政区划>
     *
     * @param sysOrganizationAreaRequest
     * @return com.shinho.tntframe.core.common.model.JsonResult<java.util.List<com.shinho.crm.base.api.dto.response.organization.SysOrganizationAreaDto>>
     * @author xy
     * @date 2019/8/8 18:43
     */
    @ApiOperation(value = "查询组织已有行政区划", notes = "查询组织已有行政区划")
    @PostMapping(value = "/listByOrganizationId")
    public JsonResult<List<SysOrganizationAreaDto>> listByOrganizationId(@RequestBody SysOrganizationAreaRequest sysOrganizationAreaRequest) {
        List<SysOrganizationAreaDto> list = sysOrganizationAreaService.listByOrganizationId(sysOrganizationAreaRequest);
        JsonResult<List<SysOrganizationAreaDto>> jsonResult = new JsonResult<>();
        jsonResult.setMsg(HttpStatusEnum.OK.getMessage());
        jsonResult.setCode(HttpStatusEnum.OK.getCode());
        jsonResult.setData(list);
        return jsonResult;
    }

}
